# -*- coding:utf-8 -*-
__author__ = 'xigu007'
from kivy.metrics import dp, sp
from kivy.uix.boxlayout import BoxLayout
from kivy.properties import StringProperty,ListProperty
from kivy.lang import Builder
from composite_widget.base import RelativeComposite,Division
from composite_widget.content import LabelContent, ImageContent, ShapeContent

Builder.load_string('''
<IconButton@Division>
    text: ''
    ico: ''
    #内容垂直布局,垂直布局时内容只能居中显示
    orientation: 'vertical'
    Division:
        weight: 7
        contents_typesetting: 'anchor'
        ImageContent:
            size_hint: None,0.8
            source: root.ico
            #设置下边距4
            margin: 0,0,0,3
            anchor: 'center'
            align: 'bottom'
    Division:
        weight: 3
        contents_typesetting: 'anchor'
        LabelContent:
            #设置上边距4
            margin: 0,0,4,0
            text: root.text
            color: 0.25,0.25,0.25,1
            anchor: 'center'
            align: 'top'


<Example3>
    #设置为白色背景
    canvas.before:
        Color:
            rgb: 1,1,1
        Rectangle:
            pos: 0,0
            size: self.size
    orientation: 'vertical'
    #上边部分
    Division:
        IconButton:
            text: '美食'
            ico: 'res/home_icons/20160126194705meishi.png'
        IconButton:
            text: '电影'
            ico: 'res/home_icons/20160126202805dianying.png'
        IconButton:
            text: '酒店'
            ico: 'res/home_icons/20160126203337jiudian.png'
        IconButton:
            text: '休闲娱乐'
            ico: 'res/home_icons/20160126203103xiuxianyule.png'
        IconButton:
            text: '外卖'
            ico: 'res/home_icons/20160126203251waimai.png'

    #下边部分
    Division:
        IconButton:
            text: '火锅'
            ico: 'res/home_icons/20160204172927huoguo.png'
        IconButton:
            text: '丽人'
            ico: 'res/home_icons/20160126202918liren.png'
        IconButton:
            text: '周边游'
            ico: 'res/home_icons/20160126203440zhoubianyou.png'
        IconButton:
            text: '生活服务'
            ico: 'res/home_icons/20160126205426shenghuofuwu.png'
        IconButton:
            text: '度假套餐'
            ico: 'res/home_icons/20160126205135jingguan.png'
''')

class Example3(RelativeComposite):
    pass
